package com.hd.trans.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class MyEditText extends androidx.appcompat.widget.AppCompatEditText {
    public MyEditText(@NonNull Context context) {
        this(context, null);
    }

    public MyEditText(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, android.R.attr.editTextStyle);
    }

    public MyEditText(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        getParent().requestDisallowInterceptTouchEvent(true);
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTextContextMenuItem(int id) {
        if (listenner != null)
            listenner.onTextmanager(id);
        /*switch (id) {
            case android.R.id.selectAll:

                break;
            case android.R.id.undo:

                break;
            case android.R.id.copy:
                break;
            case android.R.id.redo:
                break;
            case android.R.id.cut:
                break;
            case android.R.id.paste:

                break;

            case android.R.id.shareText:
                break;
            case android.R.id.replaceText:
                break;
            case android.R.id.pasteAsPlainText:
                break;
        }*/
        return super.onTextContextMenuItem(id);
    }

    private OntextManagerListenner listenner;

    public interface OntextManagerListenner {
        void onTextmanager(int id);
    }

    public void setTextManagerListenner(OntextManagerListenner listenner) {
        this.listenner = listenner;
    }
}
